using System;
using System.Web;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using AjaxControlToolkit;
using EcsSiteDSTableAdapters;
using SiteECSWeb;



/// <summary>
/// Summary description for AutoCompleteService
/// </summary>
namespace SiteECSWeb
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class AutoCompleteService : System.Web.Services.WebService
    {

        public AutoCompleteService()
        {

            //Uncomment the following line if using designed components 
            //InitializeComponent(); 
        }

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string[] GetWCompanies(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 5;
            }
            WcompanyBLL wcompanyAPI = new WcompanyBLL();
            EcsSiteDS.WcompanyDataTable wcompanyTable = 
                wcompanyAPI.GetWcompanyByFullNameEnFrstLetter(prefixText,count);

            List<string> items = new List<string>(count);
            
            for (int i = 0; i < wcompanyTable.Rows.Count; i++)
            {
                string strname = wcompanyTable.Rows[i][3].ToString();//[i][5].ToString();
                items.Add(strname);
            }
            return items.ToArray();
        }
        [WebMethod]
        public string[] GetExOpportunities(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 5;
            }
            ExpOppBLL expOppAPI = new ExpOppBLL();
            EcsSiteDS.ExpOpprtintyDataTable exOppTable =
                expOppAPI.GetExpOpprtintyByyExpOppNmArFrstLetter(prefixText, count);

            List<string> items = new List<string>(count);

            for (int i = 0; i < exOppTable.Rows.Count; i++)
            {
                string strname = exOppTable.Rows[i][1].ToString();//[i][5].ToString();
                items.Add(strname);
            }
            return items.ToArray();
        }
        private EcsSiteDS.WcompanyDataTable GetTheData(string prefixText)
        {
            WcompanyBLL wcompanyAPI = new WcompanyBLL();
            EcsSiteDS.WcompanyDataTable wcompanyTable = wcompanyAPI.GetAllWcomapny();
            wcompanyTable.DefaultView.RowFilter = "(Wcomp_fulnmen LIKE '" + prefixText + "%')";
            return wcompanyTable;
        }

    }
}
